<template>
  <div id="mine" class="mine">
	  <UserInfo></UserInfo>

    <div id="mineCell" class="mineCell">
	    <group class="mineCellGroup" v-if="adminFlag == true">
		    <cell class="mineCell" :title="sysManage" @click.native="onClick('sysManage')">
			    <img slot="icon" class="mine_icon" src="../../assets/svg/icon_system.svg">
		    </cell>
	    </group>
	    <group class="mineCellGroup">
		    <cell class="mineCell" :title="selfManage" @click.native="onClick('selfManage')">
			    <img slot="icon" class="mine_icon" src="../../assets/svg/icon_self.svg">
		    </cell>
	    </group>
    </div>
  </div>
</template>

<script>
	import bus from '@/event/eventBus'
	import UserInfo from '@/components/mobile/oss/userInfo'
  import {Divider, Card, Cell, Group} from 'vux'
  export default {
    name: "mine",
    components: {
      Divider,
      Card,
      Cell,
      Group,
	    UserInfo
    },
    data() {
      return {
        name: '刘中海',
        cardTitle: '个人信息',
        title: '职位',
	      AIReport: '智能报表',
        employeeManage: '员工管理',
	      roleManage: '角色管理',
	      sysManage: '系统管理',
	      performanceManage: '绩效管理',
	      HRManage: 'HR管理',
	      selfManage: '个人设置',
	      test: '测试',
	      adminFlag: false,
	      teacherFlag: false
      }
    },
	  created: function () {
		  bus.$emit("barController", 0)
		  bus.$emit("userDefinedEvent", 4)

    	let sysUser = this.$store.state.user.userModel.sysUser
		  let sysRoleList = this.$store.state.user.userModel.sysRoleList
		  this.name = sysUser.nickname
		  for(var i=0; i<sysRoleList.length; i++){
    		switch(sysRoleList[i].role_name){
			    case 'admin':
			    	this.adminFlag = true
				    break
			    case 'teacher':
			    	this.teacherFlag = true
				    break
			    default:
			    	break
		    }
		  }
	  },
	  methods: {
		  testNotify: function () {
			  window.JPush.getRegistrationID(this.onGetRegistrationID)
		  },
		  onGetRegistrationID(data){
		  	try{
		  		alert("JPushPlugin:registrationID is " + data)

				  if(data.length == 0){
		  			var t1 = window.setTimeout(getRegistrationID, 1000)
				  }
				  this.regid = data
			  } catch(exception){
		  		console.log(exception)
			  }
		  },
		  onClick: function(value) {
		  	switch(value){
				  case 'AIReport':
					  this.$router.push('AIReport')
					  break
				  case 'performanceManage':
					  this.$router.push('performanceManage')
					  break
				  case 'roleManage':
					  this.$router.push('roleManage')
					  break
				  case 'sysManage':
					  this.$router.push('sysManage')
					  break
				  case 'selfManage':
					  this.$router.push('selfManage')
					  break
				  case 'lessonTable':
					  this.$router.push('lessonTable')
					  break
				  default:
				  	break
			  }
		  }
	  }
  }
</script>

<style lang="less">
  @import '~vux/src/styles/1px.less';

  .card-demo-flex {
    display: flex;
  }
  .card-demo-content01 {
    padding: 10px 0;
  }
  .card-padding {
    padding: 15px;
  }
  .card-demo-flex > div {
    flex: 1;
    text-align: center;
    font-size: 12px;
  }
  .card-demo-flex span {
    color: #f74c31;
  }

  .mine{
	  background: #8080800d;
    margin-top: 56px;
	  margin-bottom: 100px;
  }

	.mineCell{
		padding: 0 0 !important;
	}

	.mine_icon {
		width: 20px;
		display: block;
		margin-right: 25px;
		margin-left: 10px;
	}

	.mineCellGroup {
		border-radius: 0px !important;
	}

</style>
